/*
 * GeoVISTA Center (Penn State, Dept. of Geography)
 * Copyright (c), 2003-2011,  Jin Chen and Alan M. MacEachren, GeoVISTA Center, Penn State University
 * Licensed under Simplified BSD License
 *
 *
 * @author: jin Chen 
 * @date: Dec 30, 2005$
 * @version: 1.0
 */
package edu.psu.geovista.app.pcp.plot.control.gui;

import edu.psu.geovista.app.pcp.plot.control.ConfigManager;
import edu.psu.geovista.app.pcp.plot.control.tools.BasicTool;
import edu.psu.geovista.app.pcp.plot.control.tools.PlotTool;
import edu.psu.geovista.app.pcp.plot.layer.AxisLayer;
import edu.psu.geovista.app.pcp.plot.layer.ConfigInfo;
import edu.psu.geovista.app.pcp.toolkits.gui.EvenRowSectionsPane;

public class MiscellaneousPane extends EvenRowSectionsPane {
    private boolean showYAxisLabel=true;
    private boolean showYAxisFoot=true;
    private boolean showFilterTick=true;
    private javax.swing.JCheckBox showYAxisLabelCb;
    private javax.swing.JCheckBox showYAxisFootCb;
    private javax.swing.JCheckBox showFilterTickCb;
    //private Pcp pcp;
    private ConfigManager cfgMgr;
    public MiscellaneousPane(ConfigManager cfg) {

         this.cfgMgr=cfg;
         //initValues() ;
        /* if(cfg!=null)  {
            pcp=cfg.getTargetUI().getPlot();

        }*/
        this.setLayout(3,1);
        this.mainP.setBorder(null);
        initComponents();
        this.addToMainPane(showYAxisLabelCb);
        this.addToMainPane(showYAxisFootCb);
        this.addToMainPane(showFilterTickCb);
        this.clearControlPane();
        reset();
    }

      public void reset(){
       /*boolean updateSizeOnDrag=((Boolean)cfgMgr.getConfigProperty(Settings.APPR_AUTOFIT)).booleanValue() ;
       boolean fillVertically=((Boolean)cfgMgr.getConfigProperty(Settings.APPR_FITV)).booleanValue() ;
       boolean fillHorizontally=((Boolean)cfgMgr.getConfigProperty(Settings.APPR_FITH)).booleanValue() ;

       this.setFillHorizontally(fillHorizontally);     //        fillHorizontally
       this.setFillVertically(fillVertically);

       this.updateOnDrag.setSelected(updateSizeOnDrag);*/
       //this.fillVert.setSelected(fillVertically);
       //this.fillHorizon.setSelected(fillHorizontally);


    }

 /* private void updateOnDragActionPerformed(java.awt.event.ActionEvent evt) {
     this.updateSizeOnDrag =this.updateOnDrag.isSelected() ;
     // Add your handling code here:
 }*/
    private void setShowLabel(boolean show) {
     PlotTool plotCmd=(PlotTool)cfgMgr.getCmd(BasicTool.PlotT );
     if(plotCmd!=null)plotCmd.setAConfigInfo(ConfigInfo.TARGET_AXIS, AxisLayer.AxisLayerConfigInfo.ShowLabel,show ) ;
    }
     private void showYAxisFoot(boolean show) {
        PlotTool plotCmd=(PlotTool)cfgMgr.getCmd(BasicTool.PlotT );
        plotCmd.setAConfigInfo(ConfigInfo.TARGET_AXIS, AxisLayer.AxisLayerConfigInfo.ShowYAxisFoot,show ) ;
     }
     private void showFilterTick(boolean show) {
         PlotTool plotCmd=(PlotTool)cfgMgr.getCmd(BasicTool.PlotT );
        plotCmd.setAConfigInfo(ConfigInfo.TARGET_AXIS, AxisLayer.AxisLayerConfigInfo.ShowFilterTick,show ) ;
     }
    private void initComponents() {
        showYAxisLabelCb = new javax.swing.JCheckBox();
        showYAxisFootCb = new javax.swing.JCheckBox();
        showFilterTickCb = new javax.swing.JCheckBox();

        if (cfgMgr==null||cfgMgr.getTargetUI()==null) return;


            Boolean showYAxisfoot = (Boolean) this.cfgMgr.getConfigSetting(AxisLayer.AxisLayerConfigInfo.ShowYAxisFoot);
            if(showYAxisfoot!=null){

            Boolean showftk = (Boolean) this.cfgMgr.getConfigSetting(AxisLayer.AxisLayerConfigInfo.ShowFilterTick);
            if(showftk !=null){
                this.showFilterTick=showftk;
            }
            Boolean showYAxLb = (Boolean) this.cfgMgr.getConfigSetting(AxisLayer.AxisLayerConfigInfo.ShowLabel);
            if(showYAxLb !=null){
                this.showYAxisLabel=showYAxLb;
            }
        }


        showYAxisLabelCb.setSelected(showYAxisLabel);
        showYAxisLabelCb.setText("Show YAxis labels");
        showYAxisLabelCb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
               setShowLabel(showYAxisLabelCb.isSelected());
            }


        });
        setShowLabel(showYAxisLabelCb.isSelected());
        //showYAxisLabelCb.doClick();


        showYAxisFootCb.setSelected(showYAxisFoot);
        showYAxisFootCb.setText("Show YAxis foot");
        showYAxisFootCb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
               showYAxisFoot(showYAxisFootCb.isSelected());
            }


        });
       showYAxisFoot(showYAxisFootCb.isSelected());


        showFilterTickCb.setSelected(showFilterTick);
        showFilterTickCb.setText("Show Filter tick");
        showFilterTickCb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
               showFilterTick(showFilterTickCb.isSelected());
            }
        });
         showFilterTick(showFilterTickCb.isSelected());

    }




}